#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <wait.h>
int main(int argc, char **argv)
{
	pid_t pid = fork();
	if (-1 == pid){
		perror ("fork()");
		return -1;
	}
	if(0 == pid){
		//修改进程组
		setpgid(getpid(), getpid());
		printf("child: pid = %d pgid = %d sid = %d\n", \
				getpid(), getpgid(getpid()), getsid(getpid()));
		exit(0);
	}else{
		wait(NULL);
		printf("child: pid = %d pgid = %d sid = %d\n", \
                  getpid(), getpgid(getpid()), getsid(getpid()));
	}
	return 0;
}
